package com.itheima_01.test;
import java.util.ArrayList;
public class Demo2 {
        public static void main(String[] args) {
            ArrayList<Teacher> list=new ArrayList<>();
            Teacher tea=new Teacher("果果老师","javase");
            Teacher tea1=new Teacher("张三丰老师","javaee");
            Teacher tea2=new Teacher("张无忌老师","php");
            Teacher tea3=new Teacher("张有忌老师","python");
            list.add(tea);
            list.add(tea1);
            list.add(tea2);
            list.add(tea3);
            for (int i = 0; i < list.size(); i++) {
                System.out.println("姓名："+list.get(i).getName()+","+"专业:"+list.get(i).getCourse());
            }
            System.out.println();
        /*System.out.println("专业:");
        for (int i = 0; i < list.size(); i++) {
            if (list.size() - 1 == i) {
                System.out.print(list.get(i).getCourse() );
            } else {
                System.out.print(list.get(i).getCourse() + ",");
            }
        }*/
            System.out.print("专业:"+list.get(0).getCourse()+","+list.get(1).getCourse()+","+list.get(2).getCourse()+","+list.get(0).getCourse());
        }
    }



